<?php

class SiteController extends Controller
{
	/**
	 * This is the default 'index' action that is invoked
	 * when an action is not explicitly requested by users.
	 */
	public function actionIndex()
	{
        Yii::app()->clientScript->registerCoreScript('jquery');
        Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl(true).'/js/jquery.nicescroll.js');
        Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl(true).'/js/jquery.mousewheel.js');

		$images = Images::getAllImages();

        $this->render('index',array('images'=>$images));
	}

    public function actionCategory($cat)
    {
		Yii::app()->clientScript->registerCoreScript('jquery');
		Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl(true).'/js/jquery.nicescroll.js');
		Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl(true).'/js/jquery.mousewheel.js');

		$images = Images::getImages($cat);

		$this->render('index',array('images'=>$images));
    }

	/**
	 * This is the action to handle external exceptions.
	 */
	public function actionError()
	{
		if($error=Yii::app()->errorHandler->error)
		{
			if(Yii::app()->request->isAjaxRequest)
				echo $error['message'];
			else
				$this->render('error', $error);
		}
	}
}